﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Drawing;

namespace HA.Data
{
    [Serializable]
   public class DisplayOption:ICloneable 
    {

        public DisplayOption()
        {
            this._zMagnification = 1;


            this._grid3d = new DOGrid3d();

            this._map = new DOMap();

            this._modflow = new DOModFlow();

            this._particles = new DOParticles();

        }


        #region 事件模型

        [field: NonSerialized]
        public event EventHandler<DisplayOptionsChangedEventArgs> DisplayOptionsChanged;

        public void AskDisplayOptionChanged(DisplayOptionsChangedEventArgs e)
        {
            if (DisplayOptionsChanged!=null)
            {
                DisplayOptionsChanged(this,e);
                
            }
 
        }


        #endregion


       

        #region 公共属性

        double _zMagnification;

        public double ZMagnification
        {
            get { return _zMagnification; }
            set
            {
                _zMagnification = value;
                if (this._zMagnification <= 0)
                {
                    this._zMagnification = 1;
                }
            }
        }

        Color _backColor = Color.White;


        /// <summary>
        /// 
        /// 背景色
        /// </summary>
        public Color BackColor
        {
            get { return _backColor; }
            set { _backColor = value; }
        }


        
        

        DOGrid3d _grid3d;

        public DOGrid3d Grid3d
        {
            get { return _grid3d; }
          
        }

        DOMap _map;

        public DOMap Map
        {
            get { return _map; }
           
        }

        DOModFlow _modflow;

        public DOModFlow Modflow
        {
            get { return _modflow; }
         
        }

        DOParticles _particles;

        public DOParticles Particles
        {
            get { return _particles; }
          
        }


        public object Clone()
        {
            DisplayOption obj = new DisplayOption();


            
            obj =(DisplayOption) this.MemberwiseClone();
            //obj.Grid3d = obj.Grid3d.c
             obj ._map= (DOMap)this.Map.Clone();
            obj ._modflow=(DOModFlow)this ._modflow .Clone ();
            //obj ._particles =(DOParticles )this ._particles .
            return obj;

        }


  

        #endregion


        #region 公共函数


        /// <summary>
        /// 判断对应的选项改变，并作出对应的更新动作
        /// </summary>
        /// <param name="doSetup"></param>
        public void ResetDisplayOption(DisplayOption doSetup)
        {

            List<string> commonChanges = new List<string>();

            if (this._backColor!=doSetup.BackColor)
            {
                this.BackColor = doSetup.BackColor;

                commonChanges.Add("BackColor");

                
            }

            if (this.ZMagnification != doSetup.ZMagnification)
            {
                this.ZMagnification = doSetup.ZMagnification;
                commonChanges.Add("ZMagnification");
            }

            //其他的属性 。。。


            if (commonChanges.Count>0)
            {
                this.AskDisplayOptionChanged(new DisplayOptionsChangedEventArgs(this, DisplayOptionsType.Common,commonChanges));
                
            }


            List<string> grid3dChanges = this.Grid3d.ResetDOGrid3d(doSetup.Grid3d);

            if (grid3dChanges != null)
            {
                if (grid3dChanges.Count > 0)
                {
                    this.AskDisplayOptionChanged(new DisplayOptionsChangedEventArgs(this, DisplayOptionsType.Grid3D, grid3dChanges));

                }
            }

            List<string> doMapsChanges = this.Map.ResetDOMap(doSetup.Map);
            if (doMapsChanges != null)
            {
                if (doMapsChanges.Count > 0)
                {
                    this.AskDisplayOptionChanged(new DisplayOptionsChangedEventArgs(this, DisplayOptionsType.MapData, doMapsChanges));
                }
            }

            List<string> doModFlowChanges = this.Modflow.ResetDOModflow(doSetup.Modflow);
            if (doModFlowChanges != null)
            {
                if (doModFlowChanges.Count > 0)
                {
                    this.AskDisplayOptionChanged(new DisplayOptionsChangedEventArgs(this, DisplayOptionsType.ModFlow, doModFlowChanges));
                }
            }
 
        }




        #endregion




    }
}
